/*********************************************************************
	Rhapsody	: 7.5.2
	Login		: dan
	Component	: TPkg_RobotController_Comp
	Configuration 	: DefaultConfig
	Model Element	: TCon_RobotController
//!	Generated Date	: Sat, 18, Dec 2010 
	File Path	: TPkg_RobotController_Comp/DefaultConfig/TPkg_RobotController/TCon_RobotController.java
*********************************************************************/

package TPkg_RobotController;

//## dependency RobotPkg 
import RobotPkg.*;
//## classInstance itsRobotController 
import RobotPkg.RobotController;
//## auto_generated
import com.ibm.rational.rhapsody.oxf.*;
//## auto_generated
import org.btc.TestConductor.TestConductor;
//## auto_generated
import com.ibm.rational.rhapsody.animation.*;
//## auto_generated
import com.ibm.rational.rhapsody.oxf.states.*;
//## auto_generated
import com.ibm.rational.rhapsody.animcom.animMessages.*;

//----------------------------------------------------------------------------
// TPkg_RobotController/TCon_RobotController.java                                                                  
//----------------------------------------------------------------------------

//## package TPkg_RobotController 


//## class TCon_RobotController 
public class TCon_RobotController implements RiJActive, RiJStateConcept, Animated {
    
    protected RiJThread m_thread;		//## ignore 
    
    public Reactive reactive;		//## ignore 
    
    protected  int testcase_terminated;		//## attribute testcase_terminated 
    
    protected DummyDriver_of_RobotController itsDummyDriver_of_RobotController;		//## classInstance itsDummyDriver_of_RobotController 
    
    protected RobotController itsRobotController;		//## classInstance itsRobotController 
    
    //#[ ignore
    // Instrumentation attributes (Animation)
    private Animate animate;
    
    public static AnimClass animClassTCon_RobotController = new AnimClass("TPkg_RobotController.TCon_RobotController",false);
    //#]
    
    
    //## statechart_method 
    public RiJThread getThread() {
        return reactive.getThread();
    }
    
    //## statechart_method 
    public void schedTimeout(long delay, long tmID, RiJStateReactive reactive) {
        getThread().schedTimeout(delay, tmID, reactive);
    }
    
    //## statechart_method 
    public void unschedTimeout(long tmID, RiJStateReactive reactive) {
        getThread().unschedTimeout(tmID, reactive);
    }
    
    //## statechart_method 
    public RiJEventConsumer getEventConsumer() {
        return (RiJEventConsumer)reactive;
    }
    
    //## statechart_method 
    public void gen(RiJEvent event) {
        reactive._gen(event);
    }
    
    //## statechart_method 
    public void queueEvent(RiJEvent event) {
        reactive.queueEvent(event);
    }
    
    //## statechart_method 
    public void cancelEvent(RiJEvent event) {
        m_thread.cancelEvent(event);
    }
    
    //## statechart_method 
    public int takeEvent(RiJEvent event) {
        return reactive.takeEvent(event);
    }
    
    //## statechart_method 
    public void run() {
        m_thread.run();
    }
    
    //## statechart_method 
    public void start() {
        m_thread.start(this);
    }
    
    // Constructors
    
    //## auto_generated 
    public  TCon_RobotController(RiJThread p_thread) {
        try {
            animInstance().notifyConstructorEntered(animClassTCon_RobotController.getUserClass(),
               new ArgData[] {
               });
        
        m_thread = new RiJThread("TCon_RobotController");
        reactive = new Reactive(m_thread);
        initRelations(m_thread);
        }
        finally {
            animInstance().notifyMethodExit();
        }
        
    }
    
    //## operation Code_tc_0() 
    public void Code_tc_0() {
        try {
            animInstance().notifyMethodEntered("Code_tc_0",
               new ArgData[] {
               });
        
        //#[ operation Code_tc_0() 
            synchronized(this) {	
            try {
        	  itsRobotController.gen(new evOnOff());
        
        	  wait(2000);         
        
        	   TestConductor.ASSERT_NAME("Robot on",itsRobotController.isIn(RobotController.on));   
        	    for(int i=0; i<6; i++) {
        	  		Sensor sensor = itsRobotController.getSensor(i);
        	  		TestConductor.ASSERT_NAME("Sensor initial value",sensor.getLine() == false);
        	   		sensor.gen(new lineSeen());
        	   		wait(200);
        	  		TestConductor.ASSERT_NAME("Sensor state change", sensor.getLine() == true);
        	  	}
        	  	itsRobotController.gen(new evOnOff()); 
        	} catch(Exception e) 
        	{ e.printStackTrace();}  
           }
        
        
        
        //#]
        }
        finally {
            animInstance().notifyMethodExit();
        }
        
    }
    
    //## operation SC_tc_0() 
    public void SC_tc_0() {
        try {
            animInstance().notifyMethodEntered("SC_tc_0",
               new ArgData[] {
               });
        
        //#[ operation SC_tc_0() 
        testcase_terminated = 0;
        TCSC_tc_0 tc = new TCSC_tc_0(this,itsRobotController,RiJMainThread.instance());
        tc.startBehavior();
        
        //#]
        }
        finally {
            animInstance().notifyMethodExit();
        }
        
    }
    
    //## operation rtc_TCSC_tc_0(TCSC_tc_0) 
    public void rtc_TCSC_tc_0(final TCSC_tc_0 p1) {
        //#[ operation rtc_TCSC_tc_0(TCSC_tc_0) 
        //#]
    }
    
    //## operation rtc_exit() 
    public void rtc_exit() {
        try {
            animInstance().notifyMethodEntered("rtc_exit",
               new ArgData[] {
               });
        
        //#[ operation rtc_exit() 
        // The following code is auto generated by TestConductor
        //////////////////////////////////////////////////////////////
        
        //#]
        }
        finally {
            animInstance().notifyMethodExit();
        }
        
    }
    
    //## operation rtc_init() 
    public void rtc_init() {
        try {
            animInstance().notifyMethodEntered("rtc_init",
               new ArgData[] {
               });
        
        //#[ operation rtc_init() 
        // The following code is auto generated by TestConductor
        //////////////////////////////////////////////////////////////
        
        //#]
        }
        finally {
            animInstance().notifyMethodExit();
        }
        
    }
    
    //## auto_generated 
    public  int getTestcase_terminated() {
        return testcase_terminated;
    }
    
    //## auto_generated 
    public void setTestcase_terminated( int p_testcase_terminated) {
        testcase_terminated = p_testcase_terminated;
    }
    
    //## auto_generated 
    public DummyDriver_of_RobotController getItsDummyDriver_of_RobotController() {
        return itsDummyDriver_of_RobotController;
    }
    
    //## auto_generated 
    public DummyDriver_of_RobotController newItsDummyDriver_of_RobotController() {
        itsDummyDriver_of_RobotController = new DummyDriver_of_RobotController();
        animInstance().notifyRelationAdded("itsDummyDriver_of_RobotController", itsDummyDriver_of_RobotController);
        return itsDummyDriver_of_RobotController;
    }
    
    //## auto_generated 
    public void deleteItsDummyDriver_of_RobotController() {
        animInstance().notifyRelationRemoved("itsDummyDriver_of_RobotController", itsDummyDriver_of_RobotController);
        itsDummyDriver_of_RobotController=null;
    }
    
    //## auto_generated 
    public RobotController getItsRobotController() {
        return itsRobotController;
    }
    
    //## auto_generated 
    public RobotController newItsRobotController(RiJThread p_thread) {
        itsRobotController = new RobotController(p_thread);
        animInstance().notifyRelationAdded("itsRobotController", itsRobotController);
        return itsRobotController;
    }
    
    //## auto_generated 
    public void deleteItsRobotController() {
        animInstance().notifyRelationRemoved("itsRobotController", itsRobotController);
        itsRobotController=null;
    }
    
    //## auto_generated 
    protected void initRelations(RiJThread p_thread) {
        itsDummyDriver_of_RobotController = newItsDummyDriver_of_RobotController();
        itsRobotController = newItsRobotController(p_thread);
        itsDummyDriver_of_RobotController.setItsRobotController(itsRobotController);
    }
    
    //## auto_generated 
    public boolean startBehavior() {
        boolean done = true;
        done &= itsRobotController.startBehavior();
        done &= reactive.startBehavior();
        if(done)
            {
                start();
            }
        return done;
    }
    
    //## ignore 
    public class Reactive extends RiJStateReactive implements AnimatedReactive {
        
        // Default constructor 
        public Reactive() {
            this(RiJMainThread.instance());
        }
        
        
        // Constructors
        
        public  Reactive(RiJThread p_thread) {
            super(p_thread);
        }
        
        /**  methods added just for design level debugging instrumentation */
        public boolean startBehavior() {
            try {
              animInstance().notifyBehavioralMethodEntered("startBehavior",
                  new ArgData[] {
                   });
              return super.startBehavior();
            }
            finally {
              animInstance().notifyMethodExit();
            }
        }
        public int takeEvent(RiJEvent event) { 
            try { 
              //animInstance().notifyTakeEvent(new AnimEvent(event));
              animInstance().notifyBehavioralMethodEntered("takeEvent",
                  new ArgData[] { new ArgData(RiJEvent.class, "event", event.toString())
                   });
              return super.takeEvent(event); 
            }
            finally { 
              animInstance().notifyMethodExit();
            }
        }
        /**  see com.ibm.rational.rhapsody.animation.AnimatedReactive interface */
        public AnimInstance animInstance() { 
            return TCon_RobotController.this.animInstance(); 
        }
        
    }
    //#[ ignore
    /**  see com.ibm.rational.rhapsody.animation.Animated interface */
    public AnimClass getAnimClass() { 
        return animClassTCon_RobotController; 
    }
    /**  see com.ibm.rational.rhapsody.animation.Animated interface */
    public Object getFieldValue(java.lang.reflect.Field f, Object userInstance) { 
         Object obj = null;
         try {
             obj = f.get(userInstance);
         } catch(Exception e) {
              System.err.println("Exception: getting Field value: " + e);
              e.printStackTrace();
         }
         return obj;
    }
    /**  see com.ibm.rational.rhapsody.animation.Animated interface */
    public AnimInstance animInstance() {
        if (animate == null) 
            animate = new Animate(); 
        return animate; 
    } 
    /**  see com.ibm.rational.rhapsody.animation.Animated interface */
    public void addAttributes(AnimAttributes msg) {
        
        msg.add("testcase_terminated", testcase_terminated);
    }
    /**  see com.ibm.rational.rhapsody.animation.Animated interface */
    public void addRelations(AnimRelations msg) {
        
        msg.add("itsRobotController", true, true, itsRobotController);
        msg.add("itsDummyDriver_of_RobotController", true, true, itsDummyDriver_of_RobotController);
    }
    /** An inner class added as instrumentation for animation */
    public class Animate extends AnimInstance { 
        public  Animate() { 
            super(TCon_RobotController.this); 
        } 
        public void addAttributes(AnimAttributes msg) {
            TCon_RobotController.this.addAttributes(msg);
        }
        public void addRelations(AnimRelations msg) {
            TCon_RobotController.this.addRelations(msg);
        }
        
    } 
    //#]
    
}
/*********************************************************************
	File Path	: TPkg_RobotController_Comp/DefaultConfig/TPkg_RobotController/TCon_RobotController.java
*********************************************************************/

